<!doctype html>
<html><!-- InstanceBegin template="/Templates/biTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<meta id="viewport" name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no,target-densitydpi=300">
<!-- InstanceBeginEditable name="doctitle" -->
<title>预警设置</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="EditRegion-jscode" -->
<link rel="stylesheet" type="text/css" href="res/common.css">
<link rel="stylesheet" type="text/css" href="../resources/css/jquery.mobile-1.1.0.min.css">
<link rel="stylesheet" type="text/css" href="../resources/css/drag_bar.css">
<script src="../resources/js/jquery-1.7.2.min.js"></script>
<script src="../resources/js/jquery.mobile-1.1.0.min.js"></script>
<script src="../resources/js/drag_bar.js"></script>
<script src="res/common.js"></script>

<script type="text/javascript">
var localStr=window.location.href,v,m,slider1_val,slider2_val;
$(function(){
	$(window).resize(function(e) {
        checkPosition();
    });
    addEventListener("load", function() { setTimeout(hideURLbar, 0);
		$("#slider1").change(function(){
			setTimeout(function(){
				c("启用当前流量提醒?","openWarn()");
			},2000);
		});
		$("#slider2").change(function(){
			setTimeout(function(){
				c("启用当前流量提醒?","openWarn()");
			},2000);
		});
	 }, false); 
	addEventListener("orientationchange", function() { setTimeout(hideURLbar, 0); }, false);
	addEventListener("load",function(){$("#loading").hide();
	$(".floatBoxBg").hide();});
      function hideURLbar(){ 
               window.scrollTo(0,1); 
      }
      if(navigator.userAgent.toLowerCase().indexOf("android", 0)<0){
         $("#footer").css({"center;z-index":"999","position":"fixed","bottom":"0"});
         window.scrollTo(0,1); 
        }else{
    $("#footer").css({"position":"fixed","bottom":"0"});
    var top = $("#footer").offset().top;
	if(localStr.indexOf("file:///",0)<0)
	{
	    $(window).scroll(function(){
	   		 $("#footer").offset({top:$(document).scrollTop()+top});
	    });
	    
	    //如果是客户端，给退出按钮绑定phoneGap写文件事件
	    $("#exitImg").bind("click",function(){
	    	onDeviceReady_exitlogin();
	    })
	}
 }
	
}); 
$(document).ready(function() {
	
	
	checkPosition();
	initbar();
	if(detectDeviceType()=="Apple"){
		$("#viewport").attr("content","width=640,initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5,user-scalable=no");
	}
	if(localStr.indexOf("file:///",0)<0&&detectDeviceType()=="Android"){
		$("#client").hide();
		$("#dlclient").show();
	}else{
		$("#client").show();
		$("#dlclient").hide();
	}
	var useragent=navigator.userAgent;
	var w=window.screen.width;
	if(useragent.indexOf("Android 4")>0)
	{
		//$("meta").attr("content","width="+w/0.78+", initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5");
	
	}
	
	if(localStorage.getItem("width")==null){
		localStorage.setItem("width",window.screen.width);
		localStorage.setItem("height",window.screen.height);
	}
	
	if(window.screen.height>window.screen.width){
		Vertical();
	}
	$( window ).bind( "resize", function() {
		//initbar();
		changeScreen();
	});
	$("#content").append('<div class="woDiv" onclick="download()"><span style="color:#49494b;">下载智能云管家客户端</span><img src="res/img/downll.png" style="padding-top:15px;"/></div>');
	
});
function initbar()
{
	var url=jsonserver+"bc/getdata/userphone/"+localStorage.getItem("curphone");
	$.getJSON(url+".jsonp?callback=?",{},
	function(data){
		$("#checkout").text(data.monthCalcDate);
		errorcheck(data.sb.status,data.sb.msg);
		if(data.warn_status=="yes"){
				$("#showStatus").text("(已开启)");
				$("#takeButton").attr("src","res/img/set_off.png");
				$("#openFlag").val("1");
				
			}else {
				$("#showStatus").text("(已关闭)");
				$("#takeButton").attr("src","res/img/set_on.png");
				$("#openFlag").val("0");
		}
		initslider("1",parseInt(data.day_over_abs),parseInt(data.day_max_abs));
		initslider("2",parseInt(data.package_over_per),parseInt(data.package_flow_total));
		if($("#openFlag").val()=="1")
		{
			$("fieldset").attr("disabled","disabled");
		}
	});
}
function changeScreen(){
	if(window.screen.height>window.screen.width){
		Vertical();
		} 
	else {
		$("#content").removeAttr("style");
		$("#mainconfig").removeAttr("style");
	}
	}
function Vertical(){
	var screenheigh = localStorage.getItem("height");
	if(screenheigh<=500){
		$("#mainconfig").get(0).style.height="723px";
	}
	else if(screenheigh>1100){
		$("#mainconfig").get(0).style.height=0.84*screenheigh+"px";
	}
	else{
		$("#mainconfig").get(0).style.height=0.85*screenheigh+"px";
	}
	}
function takeOn() 
{
	if($("#openFlag").val()=="0") 
	{
		$(".floatBoxBg").show();
		$("#loading").show();
		var urlon=jsonserver+"bc/userphone/"+localStorage.getItem("curphone")+"/day_over_abs/"+$("#slider1").attr("value")+"/package_over_per/"+$("#packageOver").text();
		$.getJSON(urlon+".jsonp?callback=?",{},function(data){
			errorcheck(data.sb.status,data.sb.msg);
				if(data.sb.status=="00000") {
				$("#takeButton").attr("src","res/img/set_off.png");
				$("#showStatus").text("(已开启)");
				$("fieldset").attr("disabled","true");
				$("#openFlag").val("1");
				}
			});
	}
	else
	{
		var urloff=jsonserver+"bc/offdata/userphone/"+localStorage.getItem("curphone");
		$.getJSON(urloff+".jsonp?callback=?",{},function(data){
			errorcheck(data.sb.status,data.sb.msg);
			if(data.sb.status=="00000") {
				$("#takeButton").attr("src","res/img/set_on.png");
				$("#showStatus").text("(已关闭)");
				$("fieldset").removeAttr("disabled");
				$("#openFlag").val("0");
				}
			});
	}
		$(".floatBoxBg").hide();
		$("#loading").hide();
}

function openWarn()
{
	$(".floatBoxBg").show();
	$("#loading").show();
		var urlon=jsonserver+"bc/userphone/"+localStorage.getItem("curphone")+"/day_over_abs/"+$("#slider1").attr("value")+"/package_over_per/"+$("#packageOver").text();
		$.getJSON(urlon+".jsonp?callback=?",{},function(data){
			errorcheck(data.sb.status,data.sb.msg);
				if(data.sb.status=="00000") {
				$("#takeButton").attr("src","res/img/set_off.png");
				$("#showStatus").text("(已开启)");
				$("fieldset").attr("disabled","true");
				$("#openFlag").val("1");
				}
		});
	$(".floatBoxBg").hide();
	$("#loading").hide();
	cancel();
}
function checkPosition()
{
	var toNum=$("#drag1");
	var inputOffset=toNum.offset();
	$("#showmsg").css({
			"width":"70%",
			"left":(inputOffset.left+10)+"px",
			"top":(inputOffset.top-70)+"px",
			"z-index":"666",
			"position":"absolute"
			});
	
	$("#childshow").css({
			"width":"70%",
			"left":(inputOffset.left+16)+"px",
			"top":(inputOffset.top-64)+"px",
			"z-index":"999",
			"position":"absolute"
			});
}
function exit(){
	localStorage.removeItem("width");
	localStorage.removeItem("height");
	window.localStorage.removeItem("curphone");
	window.localStorage.removeItem("userkey");
	localStorage.removeItem("username");
	localStorage.removeItem("innetTime");
	localStorage.removeItem("payType");//0后付费
	localStorage.removeItem("credit");
	window.localStorage.removeItem("packname");
	window.localStorage.removeItem("datasDate");
	//localStorage.clear();
	var locstr=window.location.href;
	window.location.href='../bilogin.html';
}
function c(alertText,eventName)
{
	$("#alertText").text(alertText);
	$("#okBtn").attr("onClick",eventName);	
	$("#showmsg").fadeIn();
	$("#childshow").fadeIn();
}
function cancel()
{
	$("#showmsg").fadeOut(500);
	$("#childshow").fadeOut(500);
}

</script>
<style type="text/css">
.mainConfig{
	width:100%; height:200%;
	border-radius:10px; 
	border:0px solid #dfdfdf; 
	background-color:#ffffff
}

#showmsg{
	background-color:#FFF; 
	height:280px;
	border:6px solid #8fb7df;
	opacity:0.9;
	display:none; 
	border-radius:12px;
}
#childshow
{
	background-image:url(res/index/images/bg1.jpg); 
	 height:280px;
	 display:none;
	 border-radius:12px;
}
</style>
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F883c1dc0c5cf74748ff6876f4606832f' type='text/javascript'%3E%3C/script%3E"));
</script>

<!-- InstanceEndEditable -->
<style type="text/css">
*{
	font-family:Heiti SC;
	font-weight:600;
}
</style>
	<script type="text/javascript">
//var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
//document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F2284c04845acdcd94dd640a8555927dc' type='text/javascript'%3E%3C/script%3E"));
</script>

</head>
<link rel="icon" href="res/img/logo.png" type="image/x-icon">
<link rel="shortcut icon" href="res/img/logo.png" type="image/x-icon"> 
<body style="margin:0;">

	<div id="header">
	<!-- InstanceBeginEditable name="EditRegion-header" -->
 <table width="100%" height="88px">
    	<tr>
        	<td width="10%" onClick="javascript:location.href='index.html'">
            <div style="margin-left:30px;"><img src="res/img/back.png"/></div>
            </td>
            <td width="80%">
            <span style="font-size:34px; font-weight:bold; color:#fff;">设置</span>
            </td>
            <td width="10%">
            <div style="margin-right:40px;"><img src="res/img/exit.png" onClick="c('确定退出智能云管家吗?','exit()')"/></div>
            </td>
        </tr>
    </table>
	<!-- InstanceEndEditable -->
    </div>
    <div id="content">
    <div id="loading" class="loading"><img src="res/loading.gif"/>载入中...</div>
    <div class="floatBoxBg"></div>
	<!-- InstanceBeginEditable name="EditRegion-content" -->
     <div id="childshow">
    	<!--<div style="width:100%"><img width="100%" src="res/img/billdet/jianbian.png" height="17"/></div>-->
        <div align="center" id="alertText" style="color:#4471b5; font-family:'黑体'; font-size:38px; font-weight:bold; margin-top:45px;"></div>
        <div  style="margin-top:10px;text-align:center" ><img src="res/img/billdet/hengxian.png"/></div>
         <div style=" margin-top:35px;text-align:center; "><img src="res/img/billdet/OKBtn.png" id="okBtn" /> <img src="res/img/billdet/cancelBtn.png" id="cancelBtn" width="151" height="62" onClick="cancel();" style="padding-left:15%;"/></div>
       <!-- <img width="100%" src="res/img/billdet/jianbian.png" height="15" style="width:100%; position:relative; top:38px;"/>-->
  
    </div>
	<div id="showmsg"></div>
    <div style="margin-left: 10px; margin-right: 10px; background-color:#ffffff">
    <div style="font-size:9px">&nbsp;</div>
    <table width="100%">
    	<tr>
        	<td width="65%" style="margin-top: 20px; margin-left: 30px; font-size: 36px; float:left ">流量预警<span id="showStatus" style="font-size:24px;;color:#666"></span></td>
          	<td width="40%" align="right"  style="padding-top: 20px; font-size:26px; padding-right:45px;">距月结日：<span id="checkout" style="color:#34840c"></span>天</td>
        </tr>
    </table>
     <div style="width:100%; margin-top:10px"><img src="../resources/css/images/system/images/line.png" width="100%"/></div>
    <div id="mainconfig" class="mainConfig" style="margin-top:3%; padding-bottom:30px"  >
    
   
    
    <!--Jquery Mobile -->
    <div style="margin-top: 10px; margin-left: 30px; font-size: 32px; color:#666">单日流量使用达到:</div>
    	<div style="width:200px; height:20px; text-align:center; margin-bottom:10px; font-size:26px; font-family:'黑体'; color:#494b4e;" id="showdata1"></div>
    <br/>
        <div id="drag1" style="margin-left:11%">

        </div>
        <br/>
        
		<div id="showdata11" style=" font-size:22px; font-family:'黑体';  color:#435b77;"><div style="width:50%; text-align:left; float:left;">0MB</div><div id="showmax1" style="width:50%; text-align:right;float:left;"></div></div>
        <br/>
        
         <div style="margin-top: 30px; margin-left: 30px; font-size: 32px; color:#666">套餐流量使用达到:</div>
        <div style="width:200px; height:20px; clear:both; text-align:center;margin-bottom:10px;  font-size:26px; font-family:'黑体'; color:#494b4e  ;" id="showdata2"></div>
        <br/>
 
            <div id="drag2" style="margin-left:11%">
 
            </div>  
         <br/>
        
		<div id="showdata22" style=" font-size:22px; font-family:'黑体';  color:#435b77; "><div style="width:50%; text-align:left;float:left;">0MB</div><div id="showmax2" style="width:50%; text-align:right;float:left;"></div></div>
      <!--------->      
       
            
    <div style="margin-top:60px; margin-left:30px; margin-bottom:40px; font-size: 24px; color:#666">流量超出设定值，将收到预警短信.</div>
    <div style="width:100%; text-align:center; margin-top:40px; margin-bottom:30px"><img  id="takeButton"  onClick="takeOn()"/><input type="hidden" id="openFlag" value="0"/></div>
    </div>
 
    </div>

	<!-- InstanceEndEditable -->
    </div>
    <!-- InstanceBeginEditable name="EditRegion-footer" -->
    <div id="foot" style="font-size: 24px; max-height:83px; text-align:center; background-image:url(res/img/reco_bg.png)"><div id="foot" style="margin-left: 10px; font-size: 24px"><table height="83px" width="100%" border="0">
  <tr>
    <td width="15%"><div style="max-width:101px"><img src="res/img/share_btn.png" width="100%" onClick="javascript:window.location.href='share.html'"/></div></td>
    <td><div id="dlclient" onClick="download()">下载云管家客户端，更多给力功能</div><div id="client">COOL！流量变化随时掌握</div></td>
  </tr>
</table>
</div>
   </div>

	<!-- InstanceEndEditable -->
    <div id="footer">
    </div>
    
</body>
<!-- InstanceEnd --></html>
